# coding:utf-8
# @Time      :2022/8/1611:57 PM
# @Author    :peiyu
# @FileName  :session_http_api
# @email     :geektime
# @Blog      :https://gitee.com/liupeiyu001/geektime_litemall.git
import json

from litemall.api.baseinfo import BaseInfo
from litemall.model.session import Session
import requests
from litemall.utils.log import log
from litemall.utils.readdata import Data




class SessionApi(Session):

    def __init__(self):

        self.env = Data.load_yaml('data/env.yaml')

    def refresh_token(self):

        data = {
            'username':BaseInfo.username,
            'password': BaseInfo.password
        }
        r = requests.post(
            url=BaseInfo.host+"/wx/auth/login",
            data=json.dumps(data)
        )
        # log.debug(r.json())
        return r.json()['data']['token']

